package com.ruoyi.system.service.Impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.ProjectShow;
import com.ruoyi.system.mapper.ProjectShowMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.service.IProjectShowService;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
public class ProjectShowServiceImpl  implements IProjectShowService {
    @Autowired
    private ProjectShowMapper projectShowMapper;

    @Autowired
    private TokenService tokenService;

    @Override
    public List<ProjectShow> selectProjectShowList(ProjectShow projectShow) {
        return projectShowMapper.selectProjectShowList(projectShow);
    }

    @Override
    public int insertProjectShow(ProjectShow projectShow) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        SysUser user = loginUser.getUser();
        projectShow.setCreateUser(user.getUserName());
        projectShow.setCreateTime(new Date());
        return projectShowMapper.insertProjectShow(projectShow);
    }

    @Override
    public int updateProjectShow(ProjectShow projectShow) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        SysUser user = loginUser.getUser();
        projectShow.setUpdateUser(user.getUserName());
        projectShow.setUpdateTime(new Date());
        return  projectShowMapper.updateProjectShow(projectShow);
    }

    @Override
    public ProjectShow selectProjectShowById(Long id) {
        return projectShowMapper.selectProjectShowById(id);
    }

    @Override
    public int deleteProjectShowByIds(Long[] ids) {
        return projectShowMapper.deleteProjectShowByIds(ids);
    }

}


